package com.fhz.a2102high6.test3

import android.content.SharedPreferences

/**
 * 时间:2023/9/13
 * @author Mr.Feng
 * 简述: TODO*/

fun String.countLitter() : Int{
    var count = 0
    for (s in this){
        if(s.isLetter()){
            count++
        }
    }
    return count
}
//高阶 ->  () -> Int
inline fun num1andnum2(a:Int,b:Int,haha:(Int,Int) -> Int) : Int{
    val haha1 = haha(a, b)
    return haha1
}

fun add1(a: Int,b: Int):Int{
    return a+b
}



fun StringBuilder.abc(block:StringBuilder.() -> Unit) :StringBuilder{
    block()
    return this
}

fun <T> T.abc(block:T.() -> Unit) :T{
    block()
    return this
}

fun SharedPreferences.Editor.open(block: SharedPreferences.Editor.() -> Unit) : SharedPreferences.Editor{
    block()
    return this
}



operator fun String.times(n:Int):String{
    val stringBuilder = StringBuilder()
    repeat(n){
        stringBuilder.append(this)
    }
    return stringBuilder.toString()
}

fun <T : Number> method(param: T): T {
    return param
}

infix fun String.beginWith(s:String) = startsWith(s)